/**
 * remove duplicate '/' from path
 *
 * @param path: the path to process
 * @returns: the processed path
 */
export const normalizePath = (path: string): string => {
  // do not process if path is not valid
  if (!path || path.length === 0 || path === 'undefined') {
    return path;
  }

  // replace duplicated '/'
  const res = path.replace('//', '/');
  // remove the trailing '/'
  if (res[res.length - 1] === '/') {
    return res.slice(0, res.length - 1);
  }
  return res;
};
